package com.ssyc.gsk_teacher.adapter;

import android.content.Context;
import android.widget.TextView;

import com.makeramen.roundedimageview.RoundedImageView;
import com.ssyc.common.adapter.CommonAdapter;
import com.ssyc.common.adapter.ViewHolder;
import com.ssyc.common.glide.ImageUtil;
import com.ssyc.common.http.HttpAdress;
import com.ssyc.gsk_teacher.R;
import com.ssyc.gsk_teacher.bean.StudentInfo;

import java.util.List;

/**
 * 创建日期：2017/11/10  9:57
 * 描述:展示未分组学生的ListView的适配器
 * 作者:张伟
 */

public class StudentLvAdapter extends CommonAdapter<StudentInfo> {
    private Context context;

    public StudentLvAdapter(Context context, List<StudentInfo> datas, int layoutId) {
        super(context, datas, layoutId);
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, StudentInfo personInfo) {
        //学生头像
        RoundedImageView lvHead = holder.getView(R.id.lv_student);

        //学生姓名
        TextView tvName = holder.getView(R.id.tv_student);

        //学生电话号码
        TextView tvTel = holder.getView(R.id.tv_tel);
        tvTel.setText(personInfo.getTel() + "");

        //设置服务器返回的数据
        tvName.setText(personInfo.getName());

        //设置服务器返回的头像
        String headUrl = HttpAdress.HEADIMGURL + personInfo.getIcon() + ".jpg";
        ImageUtil.displayImage(context, lvHead, headUrl);
    }
}
